<script lang="ts" setup>
    import axios from 'axios';
    import { onMounted, ref } from 'vue';
    import { useRoute } from 'vue-router';
    import type { BookDetail } from '@/type';

    let route = useRoute()
    let detailsData = ref<BookDetail|null>(null)

    onMounted(async () => {
        let res = await axios.get("http://localhost:8080/api/books/"+route.query.id,{
            headers:{
                "Authorization": "Bearer " + localStorage.getItem("token")
            }
        }
        )
        detailsData.value = res.data
    })
</script>

<template>
   <h1>书籍详情</h1>
   <div v-if="detailsData">
        <h2>id:{{ detailsData.id }}</h2>
        <h2>name:{{ detailsData.name }}</h2>
        <h2>type:{{ detailsData.type }}</h2>
   </div>
</template>

<style scoped>

</style>